package com.xiang.action;

import com.xiang.doman.Order;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

@LocalTCC
public interface OrderAction {

    /**
     * 定义两阶段提交 name = 该tcc的bean名称,全局唯一 commitMethod = commit 为二阶段确认方法 rollbackMethod = rollback 为二阶段取消方法
     * useTCCFence=true 为开启防悬挂
     * BusinessActionContextParameter注解 传递参数到二阶段中
     */
    @TwoPhaseBusinessAction(name = "tcc-order", commitMethod = "commit", rollbackMethod = "cancle", useTCCFence = true)
    void tryOrder(BusinessActionContext context, @BusinessActionContextParameter("order") Order order);

    void commit(BusinessActionContext context);

    void cancle(BusinessActionContext context);

}
